home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Str / c / strcmpcr < prev    next >
Text File  |  1995-07-08  |  2KB  |  48 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Template.strcmpcr.c
  12.     Author:  Copyright © 1993 Jason Williams
  13.     Version: 1.00 (16 May 1993)
  14.     Purpose: Compare two CR-terminated strings to see if they match
  15. */
  16.  
  17. #include "DeskLib:Str.h"
  18.  
  19.    /*
  20.     * compares the string pointed to by s1 to the string pointed to by s2.
  21.     * Returns: an integer greater than, equal to, or less than zero, according
  22.     *          as the string pointed to by s1 is greater than, equal to, or
  23.     *          less than the string pointed to by s2.
  24.     */
  25. extern int strcmpcr(char *s1, char *s2)
  26. {
  27.   register int index = 0;
  28.  
  29.   while (s1[index] > 31 && s2[index] > 31)
  30.   {
  31.     if (s1[index] > s2[index])
  32.       return(1);
  33.     else
  34.       if (s1[index] < s2[index])
  35.         return(-1);
  36.       
  37.     index++;
  38.   }
  39.  
  40.   if (s1[index] > 31)        /* s1 is longer than s2, so is greater than */
  41.     return(1);
  42.  
  43.    if (s2[index] > 31)       /* s2 is longer than s1, so result is less than */
  44.     return(-1);
  45.  
  46.   return(0);                 /* Strings exactly match */
  47. }
  48.